package com.useeinfo.oa.modules.maintaining.entity;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.framework.sugar.tools.StringConverters;
import com.useeinfo.oa.modules.base.entity.Enterprise;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @Auther: xudong.sun
 * @Date: 2019/1/10 09:43
 * @Description: 工作内容备注表
 */
@Entity
@Table(name = "work_content_remark")
public class WorkContentRemark extends SuperClassEntity<WorkContentRemark> {

    @ManyToOne
    @JoinColumn(name = "content_id")
    private MaintainOrderWorkContent maintainOrderWorkContent;


    /**
     * 问题
     */
    private String question;

    /**
     * 采取措施
     */
    private String measure;

    /**
     * 备注
     */
    private String remark;

    /**
     * 关联企业
     */
    @ManyToOne
    @JoinColumn(name = "enterprise_id")
    private Enterprise enterprise;

    public MaintainOrderWorkContent getMaintainOrderWorkContent() {
        return maintainOrderWorkContent;
    }

    public void setMaintainOrderWorkContent(MaintainOrderWorkContent maintainOrderWorkContent) {
        this.maintainOrderWorkContent = maintainOrderWorkContent;
    }


    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String getMeasure() {
        return measure;
    }

    public void setMeasure(String measure) {
        this.measure = measure;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Enterprise getEnterprise() {
        return enterprise;
    }

    public void setEnterprise(Enterprise enterprise) {
        this.enterprise = enterprise;
    }

    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = super.toJSONObject();
        jsonObject.put("question", StringConverters.null2String(getQuestion()));
        jsonObject.put("enterpriseName",StringConverters.null2String(getEnterprise().getEnterpriseName()));
        jsonObject.put("remark",StringConverters.null2String(getRemark()));
        jsonObject.put("measure",StringConverters.null2String(getMeasure()));
        jsonObject.put("contentId",getMaintainOrderWorkContent().getId());
        return jsonObject;
    }
}
